/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dxfpresentation;

/**
 *
 * @author adriano
 */
public class CubeDialog extends javax.swing.JDialog {

    /**
     * Creates new form CubeDialog
     */
    public CubeDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        lblXiCube = new javax.swing.JLabel();
        lblXfCube = new javax.swing.JLabel();
        lblYiCube = new javax.swing.JLabel();
        lblYfCube = new javax.swing.JLabel();
        lblZiCube = new javax.swing.JLabel();
        lblZfCube = new javax.swing.JLabel();
        txtXiCube = new javax.swing.JTextField();
        txtXfCube = new javax.swing.JTextField();
        txtYiCube = new javax.swing.JTextField();
        txtYfCube = new javax.swing.JTextField();
        txtZiCube = new javax.swing.JTextField();
        txtZfCube = new javax.swing.JTextField();
        btnAddCube = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Extensão"));

        lblXiCube.setText("Xi:");

        lblXfCube.setText("Xf:");

        lblYiCube.setText("Yi:");

        lblYfCube.setText("Yf:");

        lblZiCube.setText("Zi:");

        lblZfCube.setText("Zf:");

        txtXiCube.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtXiCube.setText("-2.0");

        txtXfCube.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtXfCube.setText("2.0");

        txtYiCube.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtYiCube.setText("-2.0");

        txtYfCube.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtYfCube.setText("2.0");

        txtZiCube.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtZiCube.setText("-2.0");

        txtZfCube.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtZfCube.setText("2.0");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblXiCube)
                    .addComponent(lblYiCube)
                    .addComponent(lblZiCube))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtXiCube, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
                    .addComponent(txtYiCube)
                    .addComponent(txtZiCube))
                .addGap(33, 33, 33)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblZfCube)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtZfCube))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblYfCube)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtYfCube))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblXfCube)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtXfCube, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblXiCube)
                    .addComponent(lblXfCube)
                    .addComponent(txtXiCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtXfCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblYiCube)
                    .addComponent(lblYfCube)
                    .addComponent(txtYiCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtYfCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(22, 22, 22)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblZiCube)
                    .addComponent(lblZfCube)
                    .addComponent(txtZiCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtZfCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        btnAddCube.setText("Adicionar");
        btnAddCube.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddCubeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAddCube, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnAddCube)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAddCubeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddCubeActionPerformed
        
        setBounds();
        this.dispose();
    }//GEN-LAST:event_btnAddCubeActionPerformed

    public double[] getCubeBounds()
    {
        return cubeBounds;
    }
    
    private void setBounds()
    {
        cubeBounds = new double[6];
        
        cubeBounds[0] = Double.valueOf(txtXiCube.getText()).doubleValue();
        cubeBounds[1] = Double.valueOf(txtXfCube.getText()).doubleValue();
        cubeBounds[2] = Double.valueOf(txtYiCube.getText()).doubleValue();
        cubeBounds[3] = Double.valueOf(txtYfCube.getText()).doubleValue();
        cubeBounds[4] = Double.valueOf(txtZiCube.getText()).doubleValue();
        cubeBounds[5] = Double.valueOf(txtZfCube.getText()).doubleValue();
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CubeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CubeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CubeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CubeDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the dialog
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                CubeDialog dialog = new CubeDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    private double[] cubeBounds;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddCube;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lblXfCube;
    private javax.swing.JLabel lblXiCube;
    private javax.swing.JLabel lblYfCube;
    private javax.swing.JLabel lblYiCube;
    private javax.swing.JLabel lblZfCube;
    private javax.swing.JLabel lblZiCube;
    private javax.swing.JTextField txtXfCube;
    private javax.swing.JTextField txtXiCube;
    private javax.swing.JTextField txtYfCube;
    private javax.swing.JTextField txtYiCube;
    private javax.swing.JTextField txtZfCube;
    private javax.swing.JTextField txtZiCube;
    // End of variables declaration//GEN-END:variables
}
